#!/bin/bash

# postinst script for devfs
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:sys $BASEDIR/usr/lib/devfsadm
	chown root:sys $BASEDIR/usr/lib/devfsadm/linkmod
	chmod 0555 "$BASEDIR/usr/lib/pci/pcieb"
	chown root:bin "$BASEDIR/usr/lib/pci/pcieb"
	chmod 0555 "$BASEDIR/usr/sbin/devinfo"
	chown root:bin "$BASEDIR/usr/sbin/devinfo"
	chmod 0755 "$BASEDIR/usr/lib/sysevent/modules/devfsadmd_mod.so"
	chown root:bin "$BASEDIR/usr/lib/sysevent/modules/devfsadmd_mod.so"
	chmod 0555 "$BASEDIR/usr/sbin/add_drv"
	chown root:sys "$BASEDIR/usr/sbin/add_drv"
	chmod 0555 "$BASEDIR/usr/sbin/modinfo"
	chown root:sys "$BASEDIR/usr/sbin/modinfo"
	chmod 0555 "$BASEDIR/usr/sbin/modload"
	chown root:sys "$BASEDIR/usr/sbin/modload"
	chmod 0555 "$BASEDIR/usr/sbin/modunload"
	chown root:sys "$BASEDIR/usr/sbin/modunload"
	chmod 0555 "$BASEDIR/usr/sbin/rem_drv"
	chown root:sys "$BASEDIR/usr/sbin/rem_drv"
	chmod 0555 "$BASEDIR/usr/sbin/update_drv"
	chown root:sys "$BASEDIR/usr/sbin/update_drv"
	[ -f $BASEDIR/etc/default/devfsadm ] || cp -ax $BASEDIR/usr/share/doc/devfs/examples/devfsadm $BASEDIR/etc/default/devfsadm
	chmod 0644 "$BASEDIR/etc/default/devfsadm"
	chown root:sys "$BASEDIR/etc/default/devfsadm"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_audio_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_audio_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_cfg_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_cfg_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_disk_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_disk_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_fssnap_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_fssnap_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_ieee1394_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_ieee1394_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_lofi_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_lofi_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_misc_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_misc_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_misc_link_i386.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_misc_link_i386.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_port_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_port_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_ramdisk_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_ramdisk_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_sgen_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_sgen_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_smp_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_smp_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_tape_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_tape_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_usb_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_usb_link.so"
	chmod 0755 "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_xen_link.so"
	chown root:sys "$BASEDIR/usr/lib/devfsadm/linkmod/SUNW_xen_link.so"
	chmod 0755 "$BASEDIR/usr/sbin/devfsadm"
	chown root:sys "$BASEDIR/usr/sbin/devfsadm"
	chmod 0755 "$BASEDIR/usr/sbin/getmajor"
	chown root:sys "$BASEDIR/usr/sbin/getmajor"
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

